package com.itheima.user.service.impl;

//import com.alibaba.csp.sentinel.annotation.SentinelResource;

//import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.sh.entity.UserEntity;
import com.itheima.user.mapper.UserMapper;
import com.itheima.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {


    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean login(String userName, String password) {
        QueryWrapper<UserEntity> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(UserEntity::getUserName, userName).eq(UserEntity::getPassword, password);
        UserEntity userEntity = userMapper.selectOne(wrapper);
        return userEntity != null;
    }

    @Override
    public UserEntity findUserById(Integer userId) {
        UserEntity userEntity = userMapper.selectById(userId);
        return userEntity;
    }

    // 将此方法标注为sentinel的资源。value=资源名 定义被保护的名称
//    @SentinelResource("chain")
    @Override
    public void dosomething() {
        System.out.println("chain");
    }
}
